﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using VS.Infrastructure;
using VS.MainModule.Models;

namespace VS.MainModule.Views
{
    public class ToolbarViewModel : INotifyPropertyChanged
    {
        [Dependency]
        public IRegionManager RegionManager { get; set; }
        public Collection<XamlContent> Commands { get; private set; }

        public ICommand OpenAdministration { get; set; }

        public ToolbarViewModel()
        {
            Commands = new ObservableCollection<XamlContent>()
            {
                new XamlContent()            
                {
                    Command = new DelegateCommand<XamlContent>(x => RegionManager.RequestNavigate(RegionNames.MainRegion, string.Format("/main"))),
                    Id = "home",
                    Label = "Accueil",
                    Uri = "VS.Infrastructure.Icons.home.xaml"
                },
                new XamlContent()            
                {
                    Command = new DelegateCommand<XamlContent>(x => RegionManager.RequestNavigate(RegionNames.MainRegion, string.Format("/article?id={0}", x.Id))),
                    Id = "about",
                    Label = "À propos",
                    Uri = "VS.Infrastructure.Icons.info.xaml"
                },
                new XamlContent()
                {
                    Command = new DelegateCommand<XamlContent>(x => RegionManager.RequestNavigate(RegionNames.MainRegion, string.Format("/admin"))),
                    Id = "admin",
                    Label = "Accès client",
                    Uri = "VS.Infrastructure.Icons.admin.xaml"
                }
            };

        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion

    }
}
